Skip to content

fix: don't treat ignored build scripts as failure during dep install#1237

Merged
rexxars merged 2 commits into
mainfrom
fix/pnpm-build-scripts
Jun 10, 2026
Merged

fix: don't treat ignored build scripts as failure during dep install#1237
rexxars merged 2 commits into
mainfrom
fix/pnpm-build-scripts

Conversation

@rexxars

@rexxars rexxars commented Jun 9, 2026

Copy link
Copy Markdown
Member

Description

SDK-1654

When running npm create sanity/sanity init, if selecting pnpm to use for installing dependencies you can get into this situation where pnpm installs dependencies, but exits with a non-zero exit code, and a message like:

[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: esbuild@0.28.0

Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.

We need to allow this to happen - treating it as if this was a success (which it kind of is), instead of failing the onboarding process. Since esbuild works fine for the vast majority of cases without running the postinstall script, I decided to not show the "Run 'pnpm approve-builds'" text if that is the only dependency that needs it - but open to changing/removing that, just figured it would be less noise.

Note

pnpm create sanity has a similar problem, but during the pnpx stage. This is harder to fix, but might be solved if/when #1011 lands

What to review

Does the change seem sensible?

Testing

New tests added.


Note

Low Risk
Scoped to CLI package install error handling for pnpm; real install failures still exit with an error, with broader test coverage.

Overview
Fixes pnpm dependency installs during Sanity CLI onboarding (sanity init / npm create sanity) when pnpm exits non-zero after ERR_PNPM_IGNORED_BUILDS even though packages were installed.

installPackages now runs package-manager commands with reject: false, detects ignored-build-script output (including wrapped/whitespace-separated lists), and treats that case as success. If only esbuild was skipped, no extra message is shown; for other packages (e.g. sharp, scoped names), it warns to run pnpm approve-builds. Real failures still fail the spinner but now log stdout and stderr so errors on stderr are visible. Behavior is unchanged for npm/yarn/bun.

Tests cover the new pnpm paths plus updated execa expectations; changeset is a patch for @sanity/cli.

Reviewed by Cursor Bugbot for commit 3452a2f. Bugbot is set up for automated code reviews on this repo. Configure here.

@rexxars rexxars requested a review from a team as a code owner June 9, 2026 19:40
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (73eb7a2a)

@sanity/cli

Metric Value vs main (73eb7a2)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 11.13 MB -
Bundled (gzip) 2.10 MB -
Import time 860ms -54ms, -5.9%

bin:sanity

Metric Value vs main (73eb7a2)
Internal (raw) 1023 B -
Internal (gzip) 486 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.77 MB -
Import time 1.94s -96ms, -4.7%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (73eb7a2a)

Metric Value vs main (73eb7a2)
Internal (raw) 96.3 KB -
Internal (gzip) 22.7 KB -
Bundled (raw) 21.70 MB -
Bundled (gzip) 3.45 MB -
Import time 762ms -5ms, -0.7%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (73eb7a2a)

Metric Value vs main (73eb7a2)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

squiggler-app Bot added a commit that referenced this pull request Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/util/packageManager/installPackages.ts 100.0% (±0%)

Comparing 1 changed file against main @ 73eb7a2a290a97c0c047cf5d84e6ce8c5ececf35

Overall Coverage

Metric Coverage
Statements 79.8% (- 0.5%)
Branches 71.6% (- 0.2%)
Functions 78.6% (- 0.3%)
Lines 80.3% (- 0.5%)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts Sanity CLI’s dependency installation flow to avoid failing onboarding when pnpm exits non-zero due to ignored build scripts (eg ERR_PNPM_IGNORED_BUILDS), while keeping real install failures as errors.

Changes:

  • Run package manager installs with execa(..., {reject: false}) and interpret results based on exit status + output.
  • For pnpm, treat ERR_PNPM_IGNORED_BUILDS as success and optionally warn users to run pnpm approve-builds (suppressed for esbuild-only).
  • Add/extend tests to cover ignored-build-script scenarios across installDeclaredPackages and installNewPackages.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/@sanity/cli/src/util/packageManager/installPackages.ts Adds pnpm ignored-build handling and switches installs to reject: false.
packages/@sanity/cli/src/util/packageManager/tests/installPackages.test.ts Adds test coverage for pnpm ignored-build outputs and updates expectations for reject: false.
.changeset/pr-1237.md Adds a patch changeset entry for @sanity/cli.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/@sanity/cli/src/util/packageManager/installPackages.ts
Comment thread packages/@sanity/cli/src/util/packageManager/installPackages.ts
Comment thread .changeset/pr-1237.md Outdated
@rexxars rexxars changed the title fix: dont treat ignored build scripts as failure during dep install fix: don't treat ignored build scripts as failure during dep install Jun 9, 2026
@rexxars rexxars force-pushed the fix/pnpm-build-scripts branch from 7f2f092 to 3452a2f Compare June 9, 2026 20:49
@rexxars rexxars requested a review from binoy14 June 9, 2026 21:49

@binoy14 binoy14 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rexxars rexxars merged commit eaaa4c3 into main Jun 10, 2026
53 of 54 checks passed
@rexxars rexxars deleted the fix/pnpm-build-scripts branch June 10, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants